package com.hyd.hx_adr.modules.user.controller;

import com.hyd.hx_adr.annotations.PassToken;
import com.hyd.hx_adr.domain.entity.JsonResult;
import com.hyd.hx_adr.modules.user.domain.info.LoginInfo;
import com.hyd.hx_adr.modules.user.domain.info.RegisterInfo;
import com.hyd.hx_adr.modules.user.domain.vo.LoginVo;
import com.hyd.hx_adr.modules.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public JsonResult<String> register(@RequestBody RegisterInfo info) {
        return userService.register(info);
    }

    @PassToken
    @PostMapping("/login")
    public JsonResult<LoginVo> login(@RequestBody LoginInfo info) {
        return userService.login(info);
    }
}
